package com.ang.http.okHttp;

import okhttp3.OkHttpClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.TimeUnit;

@Configuration
public class OkHttpConfig {

    @Bean("simpleOkHttpClient")
    public OkHttpClient simpleOkHttpClient() {
        OkHttpClient client = new OkHttpClient();

        return client;
    }

    @Bean("okHttpClient")
    public OkHttpClient okHttpClient() {
        OkHttpClient client = new OkHttpClient.Builder()
                .readTimeout(60, TimeUnit.SECONDS)
                .connectTimeout(60, TimeUnit.SECONDS)
                //...
                .build();

        return client;
    }
}
